﻿using JavaDevToys.Rcl.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace JavaDevToys.Rcl.Service.Impl
{
    public class JavaServiceParser : IJavaServiceParser
    {
        public List<JavaServiceInfo> Parse(string _content)
        {
            List<JavaServiceInfo> javaServiceInfos = new List<JavaServiceInfo>();
            // 分割内容为行
            string[] lines = _content.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
            for (int i = 0; i < lines.Length; i++)
            {
                var rawLine = lines[i];
                string line = rawLine.Trim();
                if (string.IsNullOrEmpty(line))
                    continue;
                string[] parts = line.Split('\t');
                JavaServiceInfo javaServiceInfo = new JavaServiceInfo()
                {
                    Code = parts[0],
                    Name = parts[1],
                    ClassName = parts[2],
                    MothedName = parts[3],
                    ModelName = parts[4],
                };
                javaServiceInfos.Add(javaServiceInfo);
            }
            return javaServiceInfos;
        }
    }
}
